package com.show.mytest;

import java.util.*;

public class Test05_DDZ {
    public static void main(String[] args) {
        ArrayList<String> colors = new ArrayList<>();
        colors.add("♠");
        colors.add("♡");
        colors.add("♣");
        colors.add("♢");
        ArrayList<String> numbers = new ArrayList<>();
        Collections.addAll(numbers,"3","4","5","6","7","8","9","10","J","Q","K","A","2");
        ArrayList<String> pokers = new ArrayList<>();
        for (String number : numbers) {
            for (String color : colors) {
                String poker = color + number;
                pokers.add(poker);
            }
        }
        pokers.add("小王");
        pokers.add("大王");
        Map<Integer,String> pokersMap = new HashMap<>();
        int j = 0;
        for (String poker : pokers) {
            pokersMap.put(j++,poker);
        }
        Set<Integer> set = pokersMap.keySet();
        List<Integer> list = new ArrayList<>();
        list.addAll(set);
        System.out.println(list);
        Collections.shuffle(list);
        System.out.println(list);


        ArrayList<Integer> player1 = new ArrayList<>();
        ArrayList<Integer> player2 = new ArrayList<>();
        ArrayList<Integer> player3 = new ArrayList<>();
        ArrayList<Integer> dipai = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            if (i <= 50) {
                if (i % 3 == 0) {
                    player1.add(list.get(i));
                } else if (i % 3 == 1) {
                    player2.add(list.get(i));
                } else {
                    player3.add(list.get(i));
                }
            }else {
                dipai.add(list.get(i));
            }
        }
//        if (player1.contains("大王")){
//            player1.addAll(dipai);
//        } else if (player2.contains("大王")){
//            player2.addAll(dipai);
//        }else {
//            player3.addAll(dipai);
//        }
        Random r = new Random();
        int i = r.nextInt(2);
        if (i == 0){
            player1.addAll(dipai);
        }else if (i == 1){
            player2.addAll(dipai);
        }else {
            player3.addAll(dipai);
        }
        lookPoker(player1,pokersMap);
        lookPoker(player2,pokersMap);
        lookPoker(player3,pokersMap);
        lookPoker(dipai,pokersMap);

    }
    public static void lookPoker(List<Integer> list,Map<Integer,String> map){
        StringBuilder sb = new StringBuilder("{");
        Collections.sort(list);
        for (int i = 0; i < list.size(); i++) {
            if (i == list.size() - 1){
                sb.append(map.get(list.get(i))).append("}");
            }else {
                sb.append(map.get(list.get(i))).append(",");
            }
        }
        System.out.println(sb.toString());
    }
}
